import JQuery from 'jquery';

let holo3dMap = {
    setAttribute: function(element) {
        if (element.component === 'Holo3dMap') {
            this.setValue(this.getModelFileAddressName(), element.data.pmtsUrl);
            this.setValue(this.getGridFileAddressName(), element.data.wmtsUrl);
            this.setValue(this.getTerrainFileAddressName(), element.data.wetsUrl);
        }
    },
    setValue: function(id, value) {
        let obj = JQuery('#' + id);
        obj.val(value);
    },
    getModelFileAddressName() {
        return window.getRootName() + 'DATA_PMTSURL';
    },
    getGridFileAddressName() {
        return window.getRootName() + 'DATA_WMTSURL';
    },
    getTerrainFileAddressName() {
        return window.getRootName() + 'DATA_WETSURL';
    },
    setModelFileUrl: function(element, value, updateInput = true) {
        element.data.pmtsUrl = value;
        updateInput && this.setValue(this.getModelFileAddressName(), element.data.pmtsUrl);
    },
    setGridFileUrl: function(element, value, updateInput = true) {
        element.data.wmtsUrl = value;
        updateInput && this.setValue(this.getGridFileAddressName(), element.data.wmtsUrl);
    },
    setTerrainFileUrl: function(element, value, updateInput = true) {
        element.data.wetsUrl = value;
        updateInput && this.setValue(this.getTerrainFileAddressName(), element.data.wetsUrl);
    }
};
export default holo3dMap;